Skip to content

Isolate the plugin test suite from host secrets - #3435

Merged
Birfy merged 1 commit into
mainfrom
dev/3434-isolate-plugin-test-host-state
Nov 29, 2026
Merged

Birfy merged 1 commit into
mainfrom
dev/3434-isolate-plugin-test-host-state

Conversation

@Birfy

@Birfy Birfy commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

The runtime/flybot-workspace-web test suite inherited the host process environment. On a machine whose /run/secrets holds the workspace runtime key (10,873 B) and seal key (32 B), and whose shell exports FLYBOT_WORKSPACE_ROUTING_INSTANCE_ID, eleven tests failed for reasons unrelated to the code under test.

What changes

One injection seam, added as optional parameters with today's defaults:

  • index.js: config.env ?? process.env; identity built from that env; the same env passed to loadFeatures.
  • src/features.js: loadFeatures({ ..., env = process.env }), featureHost({ ..., env = process.env }), exposed as host.env; the host stays frozen.
  • features/agents/index.js:1664 and :1677: loadPersonalAgentBootstrap(host.env). That loader already takes (env = process.env, reader = readFileSync), so it is unchanged.

No production call site passes env, so production behaviour is unchanged. lib/b4/seal.js is untouched, including its empty-string fallback to the host key file.

Test side: test/helpers.js exports a frozen TEST_ENV whose key paths cannot exist, boot() and deliverBundle() default to it, and the files that build feature hosts pass it explicitly. test/model-api.test.js uses a non-existent operator key path instead of an empty string, which lib/b4/seal.js treats as falsy and replaces with the host default.

Why not tests only

Eight of the eleven failures left through loadPersonalAgentBootstrap() called with no arguments, reading process.env and the real secrets path. The host object handed to a feature carried no environment and apply() hard-coded process.env, so no test-side change could reach it. Wiring that one seam is the smallest change that does.

Measured locally (not CI, not acceptance)

On node v22.23.5 with --test-concurrency=2, at the content of this head (tree 93a2fb2d):

class files before after
runtime key cascade chat, agent-api, agents 22/29 29/29
seal key fallback model-api 8/9 9/9
identity routing meetings, search 29/31 31/31

Whole directory, same head: node 22 497 tests / 493 pass / 0 fail / 4 cancelled / exit 1; node 24 497 / 497 / 0 / 0 / exit 0.

Not fixed here

The four cancelledByParent tests on node 22 (features.test.js:156, :168, memory-extras.test.js:356, :412) are an event-loop mechanism of that node version and are tracked separately. The suite is therefore not fully green on node 22 after this change, and this pull request does not claim that it is. CI is unaffected either way: the runtime image job pins node 24 and runs from a clean checkout.

Related #3434

The suite inherited the host process environment, so on a machine whose
/run/secrets holds the workspace runtime key and seal key, eleven tests
failed for reasons unrelated to the code under test.

Give the plugin an explicit environment instead. `apply()` accepts
`config.env` (defaulting to `process.env`), `loadFeatures()` and
`featureHost()` carry it as `env` (defaulting to `process.env`), and the
agents feature passes `host.env` to `loadPersonalAgentBootstrap()`, which
already takes an env object. No production call site passes `env`, so the
default keeps today's behaviour; the host object stays frozen.

The tests build identity and hosts from an explicit `TEST_ENV` object whose
key paths cannot exist, and the seal-key fallback test uses a non-existent
operator key path instead of an empty string, which `lib/b4/seal.js` treats
as falsy and replaces with the host default.

Measured locally on node v22.23.5, `--test-concurrency=2`: the three classes
this slice covers go from 22/29, 8/9 and 29/31 to 29/29, 9/9 and 31/31. The
whole directory still reports four `cancelledByParent` tests on node 22
(497 tests, 493 pass, 0 fail, 4 cancelled, exit 1) and is green on node 24
(497/497, exit 0). Those four are a node 22 event-loop mechanism tracked
separately, not part of this change.

Related #3434
@github-actions github-actions Bot added the risk:T3 Risk tier T3 (needs a human approval), set by the controller from the diff label Nov 29, 2026
@Birfy

Birfy commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Lead review record — exact head 8f70ad5932b837a7402a453f69a36584073c9fdd

Verified coordinates (REST, this session): git/refs/pull/3435/head = 8f70ad59…, commit tree 93a2fb2da2c93adfe58df4ae7f6165519c15d590, single parent 1a981717f2b708f796b820ec871058ab339b8fa2, 12 files +44/−24, message Isolate the plugin test suite from host secrets, PR open / draft false / mergeable: true / mergeable_state: clean, label risk:T3 (applied by risk-gate, not by hand).

Slice. One reviewable change: the plugin test suite stops reading host secrets, via one explicit optional env seam in production code. Four production touch points, all defaulting to process.env so the shipped behaviour is unchanged:

  • index.js:31 loadIdentity({ env, dataDir }), index.js:35 loadFeatures({ …, env })
  • src/features.js:67 loadFeatures({ …, env = process.env }), :85 featureHost({ …, env }) with env inside the existing Object.freeze
  • features/agents/index.js:1664 / :1677 pass host.env instead of calling loadPersonalAgentBootstrap() bare

Test side: test/helpers.js gains TEST_ENV pointing FLYBOT_WORKSPACE_RUNTIME_KEY_FILE / FLYBOT_WORKSPACE_SEAL_KEY_FILE at non-existent paths, used by boot() and deliverBundle(); test/model-api.test.js uses a per-test non-existent seal key. No test-only branch in production code, no edits to lib/b4/seal.js or src/host.js, no skip/only.

Acceptance evidence — local, on this head's content (QA Engineer and Runtime Dev, node v22.23.5, --test-concurrency=2; three-class breakdown, not a whole-directory claim):

  • class 1 chat + agent-api + agents: 29/29 pass, exit 0 (baseline 22/29)
  • class 2 model-api 9/9 (the ENOENT …/k/seal.key red is gone) + private-agent-files 21/21 (incl. Run the same-room acceptance choreography on a real mock-model bench #324): 30/30, exit 0 (baseline 29/30)
  • class 3 meetings + search: 31/31 pass, exit 0 (baseline 29/31)
  • class 4 whole directory, node 22: 497 / 493 pass / 0 fail / 4 cancelled / exit 1; node 24: 497 / 497 / 0 / 0 / exit 0

Acceptance evidence — CI, same head, read by me: check-runs total_count 18 == returned 18, 18/18 completed + success, 0 in_progress / failure / cancelled / neutral, every head_sha = 8f70ad59…. This is the check-run record only (FlyBot required checks, runtime-image / Build and smoke under the manager contract, runtime-image / Image recipe contract tests, upstream ×4, provenance ×3, social-host ×2, Management API ×2, browser / screenshots, silent-revert, Risk tier label, Web and compose planner); job logs were not available, so "green" here means those 18 conclusions and nothing more.

Local green and CI green are reported separately above; neither is a claim of parity or of overall acceptance.

Out of scope, deliberately not fixed here: the 4 node-22 cancelledByParent cases (#176 test/features.test.js:156, #177 :168, #233 test/memory-extras.test.js:356, #234 :412) — trace material is being filed as its own issue; the watch() residual in private-agent-files.test.js:1311; the ds_bot_bridge watchdog variant in tests/ds_bot_bridge.test.mjs. Whole-directory node 22 still exits 1 because of the first item.

Any new commit voids this record.

Related #3434

@Birfy
Birfy added this pull request to the merge queue Nov 29, 2026
Merged via the queue into main with commit e6aeae4 Nov 29, 2026
18 checks passed
@Birfy
Birfy deleted the dev/3434-isolate-plugin-test-host-state branch November 29, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:T3 Risk tier T3 (needs a human approval), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant